
#include "QBSwSectorInfo.h"
#include <fstream>
#include <string.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
//#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// class CQBSwSectorInfo

CQBSwSectorInfo::CQBSwSectorInfo()
{
}

CQBSwSectorInfo::~CQBSwSectorInfo()
{
	Clear( );
}

bool CQBSwSectorInfo::Add(QBSWSECTORINFO &info){
	std::lock_guard<std::mutex> locker(m_mutex);//TODO: lock outside?
	if(strlen(info.SW_Internal_Code) <= 0)return false;
	m_map[info.SW_Internal_Code] = info;
	return true;
}


bool CQBSwSectorInfo::Clear( )
{
	std::lock_guard<std::mutex> locker(m_mutex);
	m_map.clear();
	return true;
}

CQBSwSectorInfo& CQBSwSectorInfo::instance()
{
	static CQBSwSectorInfo s_si;
	return s_si;
}

CQBSwSectorInfo& CQBSwSectorInfo::instance2021()
{
	static CQBSwSectorInfo s_si2;
	return s_si2;
}

const QBSWSECTORINFO* CQBSwSectorInfo::GetSwSectorInfo(const std::string &id){
	std::lock_guard<std::mutex> locker(m_mutex);
	std::map<std::string, QBSWSECTORINFO>::iterator it = m_map.find(id);
	if(it != m_map.end()){
		return &it->second;
	}
	return nullptr;
}
void CQBSwSectorInfo::DumpStatus(int mode)const
{
}
